﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Usercontrol_ControlReportKHChoChamSoc : System.Web.UI.UserControl
{
    ClassExecute.ClassExecute dt;
    string str = webapp4U.Configuration.CurrentConnectionString;
    string error = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            GetData(Session["UserName"].ToString());
        }
    }
    protected void GridView2_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        dt = new ClassExecute.ClassExecute();
        GridViewRow grv = ((Control)e.CommandSource).NamingContainer as GridViewRow;
        if (e.CommandName == "XacNhan")
        {

        }
        else if (e.CommandName == "ChiTiet")
        {
            DataTable db = dt.Get_Data_DataTable(str, ref error, "K_ChiTietDonHangKhachHangChoChamSoc", CommandType.StoredProcedure,
                new SqlParameter("@tranno", grv.Cells[0].Text));
            GridView1.DataSource = db;
            GridView1.DataBind();
        }
    }
    protected void GridView2_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        GridView2.PageIndex = e.NewPageIndex;
        GetData(Session["UserName"].ToString());

    }
    void GetData(string salesp_key)
    {
        GridView2.DataSource = null;
        dt = new ClassExecute.ClassExecute();
        DataTable db = dt.Get_Data_DataTable(str, ref error, "K_KhachHangChoChamSoc", CommandType.StoredProcedure,
            new SqlParameter("@Salespkey", salesp_key));
        if (db.Rows.Count > 0)
        {
            GridView2.DataSource = db;
            
        }
        GridView2.DataBind();
    }
}